//
//  SEGYouZanViewModel.m
//  SEGViewModel
//
//  Created by 山刘 on 2020/6/1.
//

#import "SEGYouZanViewModel.h"

@implementation SEGYouZanViewModel
#pragma mark - business
-(void)requestYouZanLogin:(void(^)(NSInteger code,NSString *accessToken,NSString *cookieKey,NSString *cookieValue))cmopleted{
    [self.manager requestYouZanLogin:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        if ([result isKindOfClass:[NSDictionary class]]) {
            NSString *code = [result objectForKey:@"code"];
            if ([code integerValue] == 0) {
                cmopleted([code integerValue],result[@"data"][@"accessToken"],result[@"data"][@"cookieKey"],result[@"data"][@"cookieValue"]);
            }
            cmopleted([code integerValue],@"",@"",@"");
        }
    }];
}

#pragma mark - getter
- (SEGYouZanManager *)manager
{
    if (!_manager) {
        _manager = [[SEGYouZanManager alloc] init];
    }
    return _manager;
}
@end

